package com.rwy.web.controller;

import javax.servlet.http.HttpServletResponse;

import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rwy.util.RWYException;

import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

@Controller
@RequestMapping("/test")
public class TestController {
	@Autowired
	CacheManager cachemanger; 
	@RequestMapping("/res")
	public void test(HttpServletResponse response) throws Exception {
		
		/*try (OutputStream out = response.getOutputStream()) {
			out.write("say hello !".getBytes());
			out.flush();
		}*/
		 //throw RWYException.create(HttpStatus.SC_UNAUTHORIZED, "aaaa");
		cachemanger.getCache("users").put(new Element("aa", "aa"));
		cachemanger.getCache("users").put(new Element("aa", "aa"));
		System.out.println(cachemanger.getCache("users").get("aa").getValue());
	}
}
